package netDemo

import (
	"fmt"
	"golang.org/x/net/websocket"
)

var originTest = "http://127.0.0.1:8081/testReq" // 请求路由
var urlTest = "ws://127.0.0.1:8081/testRsp"      // 响应路由

func main() {
	ws, err := websocket.Dial(urlTest, "", originTest)
	msg := []byte("hello, test, 你好！")
	_, err = ws.Write(msg)
	fmt.Println("sendTest:", msg, err)
	fmt.Printf("Send: %s\n", msg)

	msgResp := make([]byte, 512)
	m, err := ws.Read(msg)
	fmt.Println("Receive: ", msgResp[:m])
	ws.Close()

}
